# -*- coding: utf-8 -*-
# Author:叶海波

import configparser
import sys
import os


def OppositePath():
    """相对路径"""
    dirname, filename = os.path.split(os.path.abspath(sys.argv[0]))
    return dirname


conf = configparser.ConfigParser()


# print conf.get("Account information","username")
# print conf.items("Account information")  #获取到Account information中的所有内容，返回字典类型
# print conf.options("Account information")   #获取到Account information中的变量名
#
# #向ini中添加内容
# print conf.add_section("Account")
# print conf.set("Account","title","1")
# print conf.write(open("test_cfg.ini","w+"))
#
# #向ini中修改内容
# conf.set("Account","title","6")
# conf.write(open("test_cfg.ini","w+"))

def getIni(path, section, key):
    conf.read(path + '/configuration.ini', encoding='utf-8')
    # 支持逗号分割的
    return conf.get(section, key)

def getIniStr(path, section, key):
    conf.read(path + '/configuration.ini', encoding='utf-8')
    # 支持逗号分割的
    return conf.get(section, key)

def getIniInt(path, section, key):
    conf.read(path + '/configuration.ini', encoding='utf-8')
    # 支持逗号分割的
    return int(conf.get(section, key))


if __name__ == '__main__':
    print(getIni(".", "memory", "interval"))
